package udp;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * Author:  LiuTao
 * Version: 1.0
 * Date:    2024-04-08  12:06
 */
public class UdpDictServer extends UdpEchoServer {
    private HashMap<String, String> hashMap = new HashMap<>();
    public UdpDictServer(int port) throws SocketException {
        super(port);

        hashMap.put("cat","猫");
        hashMap.put("dog","狗");
        hashMap.put("chicken","鸡");
    }

    @Override
    public String process(String request) {
        return hashMap.getOrDefault(request,"您输入的单词有误！");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9090);
        server.start();
    }
}
